# Contributor: tcely <sequoia-sqv+aports@tcely.33mail.com>
# Maintainer:
_project="sequoia"
pkgname=$_project-sqv
pkgver=0.9.0
pkgrel=4
pkgdesc="simple signature verification program"
url="https://sequoia-pgp.org/"
arch="armhf armv7 x86_64" # limited by cargo
license="GPL-3.0-or-later"
makedepends="capnproto-dev cargo clang-dev nettle-dev openssl-dev
	py3-cffi py3-pytest py3-setuptools python3-dev sqlite-dev"
source="https://gitlab.com/$_project-pgp/$_project/-/archive/v$pkgver/$_project-v$pkgver.tar.gz
	"
builddir="$srcdir/$_project-v$pkgver"

_cargo_env() {
	cd "$builddir"

	CARGO_TARGET_DIR="$PWD/target"
	export CARGO_TARGET_DIR

	SQV="$CARGO_TARGET_DIR/release/sqv"
	export SQV
}

build() {
	_cargo_env

	# Detect mismatching versions from upstream
	sed -i.orig -e '/^version =/s/=.*$/= "'"$pkgver"'"/' sqv/Cargo.toml
	diff -us sqv/Cargo.toml.orig sqv/Cargo.toml

	make -C sqv build-release CARGO_FLAGS='--locked'
}

check() {
	_cargo_env

	cd sqv && cargo test --locked --release --package "$pkgname"

	"$SQV" --version
}

package() {
	_cargo_env

	make DESTDIR="$pkgdir" -C sqv install
}

sha512sums="2349f6f12b9b20761729ba927d08d6090f0c697c2a103eaf403a5694e4303573c45c5247ebc30c080a885916f026e9618ffa979f84f0dcb055377e62a78be4ee  sequoia-v0.9.0.tar.gz"
